﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace canyinguanlixitong
{
    public partial class frmaddtable : Form
    {
        public frmaddtable()
        {
            InitializeComponent();
        }
        string strcoon = "Data Source=.;Initial Catalog=Supermarket management system;Integrated Security=True";
        private void frmaddtable_Load(object sender, EventArgs e)
        {
           add();
        }
        public void add(){
            SqlConnection conn = new SqlConnection(strcoon);
            conn.Open();
            int i =Convert.ToInt32(this.textBox1.Text);
            string quyu = this.textBox2.Text;
            string zhuangtai = this.textBox3.Text;
            string sql = @"insert into [Room type],Tablecondition,Table(fangName,czName,czID)
                values('" + i + "','" + quyu + "','" + zhuangtai + "')";
          SqlCommand cmd = new SqlCommand(sql,conn);
            int result = cmd.ExecuteNonQuery();
            if (result == 1)
            {
                MessageBox.Show("新增成功");
            }
            else {
                MessageBox.Show("新增失败");
            }

            conn.Close();
        }

        private void buttoncal_Click(object sender, EventArgs e)
        {
            this.Close();
        }
       
        }
    }

